home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga CD-ROM Collection
/
Amiga CD-ROM Collection - Auge 4000 and Cactus and Demo Util.iso
/
auge4000
/
46
/
lib
/
memory
/
cmpmem.a
< prev
next >
Wrap
Text File
|
1990-06-20
|
1KB
|
67 lines
; CMPMEM.A
;
; (c)Copyright 1990, Matthew Dillon, All Rights Reserved
section text,code
; CMPMEM (s1, s2, len)
; MEMCMP (s1, s2, len) ANSI
; BCMP (s1, s2, len) UNIX
; A0 A1 D0
; 4(sp) 8(sp) 12(sp)
xdef _cmpmem
xdef _bcmp
xdef _memcmp
_memcmp:
_cmpmem:
_bcmp:
move.l 4(sp),A0
move.l 8(sp),A1
move.l 12(sp),D1
move.w A0,D0 ; not word aligned adress.
lsr.l #1,D0
bcs xcmbyte
move.w A1,D0
lsr.l #1,D0
bcs xcmbyte
move.l D1,D0 ; save D1
lsr.l #2,D1 ; # of longwords to compare
xcmlong subq.l #1,D1
bcs xcmlbreak
xcmlloop cmpm.l (A0)+,(A1)+
dbne D1,xcmlloop
bcs xcmendp
bhi xcmendn
sub.l #$10000,D1
bcc xcmlloop
xcmlbreak
move.l D0,D1 ; get original bytes
and.l #3,D1 ; # bytes left to compare
xcmbyte subq.l #1,D1
bcs xcmbbreak
xcmbloop cmpm.b (A0)+,(A1)+
dbne D1,xcmbloop
bcs xcmendp
bhi xcmendn
sub.l #$10000,D1
bcc xcmbloop
xcmbbreak
xcmend0 moveq.l #0,D0
rts
xcmendp moveq.l #1,D0
rts
xcmendn moveq.l #-1,D0
rts
END